class_name RerollButton
extends Button

# ===============================================

@export var player_stats: PlayerStats
@export var sfx: AudioStream

# ===============================================

const REFRESH_COST: int = 2

@onready var h_box_container: HBoxContainer = $HBoxContainer


# ===============================================

func __on_player_stats_changed() -> void:
	disabled = player_stats.gold < REFRESH_COST
	if disabled:
		h_box_container.modulate.a = 0.5
	else:
		h_box_container.modulate.a = 1.0

# ===============================================

func _ready() -> void:
	player_stats.changed.connect(__on_player_stats_changed)
	__on_player_stats_changed()


func _on_pressed() -> void:
	player_stats.gold -= REFRESH_COST
	SFXPlayer.play(sfx)
